#!/usr/bin/python2.7
from os import walk, chdir, getcwd
from sys import argv
from re import match, compile, findall, M

class get_keywords:

    def __init__(self):
        config = open('get-key.cfg', 'r')
        match_root_re = compile(r'^path_to_feature =(.*)$')
        match_delimiter_re = compile(r'^d_regex = (.*)$')
        line = ''

        for line in iter(config.readline, b''):
            match_root = match_root_re.match(line)
            match_delimiter = match_delimiter_re.match(line)
            if match_root:
                self.root_value = match_root.group(1)
            elif match_delimiter:
                self.delimiter_value = match_delimiter.group(1)
        config.close


if __name__ == '__main__':
    examp = get_keywords()
    print '\ndelimiter reg = %s' % examp.delimiter_value
    print '\nroot = %s' % examp.root_value
    d = match(examp.delimiter_value, "@When('^I am on (.*) page in (google.com|yahoo.com)$')", M)
    if d:
        print d.group(1), ":\n", "\t", d.group(2)